import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'

import { useUserStore } from './stores/user'
import Cookies from 'js-cookie'
import { tokenCookieKey } from '@/config'

// 全局css
import './assets/style/reset.css'
import './assets/style/main.css'
// vant Toast，Dialog，Notify 和 ImagePreview 组件是以函数的形式提供
// unplugin-vue-components 无法自动引入对应的样式，因此需要手动引入样式
import 'vant/es/toast/style'
// 全局组件
import Page from './components/Page.vue'

const app = createApp(App)
const pinia = createPinia()

app.use(pinia)
app.use(router)

const userStore = useUserStore()
// cookie取token
const token = Cookies.get(tokenCookieKey)
token && userStore.setToken(token)

app.mount('#app')
